package org.devgframwork.demo.rabbitmq;


import org.devgframwork.rabbitmq.RabbitConsumer;
import org.devgframwork.rabbitmq.RabbitConsumerTag;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Envelope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Description
 * @auther dh
 * @date 2022/4/14 9:28
 */

@Component
@RabbitConsumerTag(exchangeName = "direct_exchange", queueName = "direct_consumer", routeKey = "direct_consumer", prefetchCount = 10)
public class RabbitDirectConsumer extends RabbitConsumer<String> {

    @Autowired
    private RabbitService rabbitService;

    @Override
    public void messageHander(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, String message) throws IOException {
        rabbitService.doMsg("direct_consumer:" + message);
    }
}
